
import nw from "nw-lafjs";
import {fail, ok} from "@/utils/responseUtil";

export default async function (ctx: FunctionContext) {
  let body = ctx.body
  /**
   * {
   *   "_id": "1",
   *   "status": 0
   * }
   */

  if (nw.util.isNull(body._id)){
    return fail("参数不合法")
  }
  if (nw.util.isNull(body.status)||!(body.status===0||body.status===1)){
    return  fail("状态不合法")
  }
  //2.直接修改即可
  let num = await nw.db.update({
    dbName:"regionWare",
    whereJson:{_id:body._id},
    dataJson:{status:body.status}
  })

  if (num===0){
    return fail("更新失败")
  }

  return ok("更新成功")


}
